package com.zxc.controller.park;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zxc.model.Page;
import com.zxc.model.ParkDaily.ParkState;
import com.zxc.model.ParkDetails;
import com.zxc.model.Pesticide;
import com.zxc.service.ParkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Controller
@CrossOrigin
@RestController
@RequestMapping("/park")
public class parkController {
    @Autowired
    private ParkService parkService;
    @RequestMapping("/getParkData")
    public ResponseEntity<?> getParkData(@RequestBody ParkState vo) {
        Page page =vo.getPageList().get(0);
        PageHelper.startPage(page.getOffset(), page.getLimit());
        return ResponseEntity.ok(new PageInfo<ParkState>(parkService.getParkData(vo)));
    }
    @RequestMapping("/setNewParkData")
    public ResponseEntity<?> setNewParkData(@RequestBody ParkState vo) {
        return ResponseEntity.ok(parkService.setNewParkData(vo));
    }
    @RequestMapping("/getPlant")
    public ResponseEntity<?> getPlant() {
        return ResponseEntity.ok(parkService.getPlant());
    }



}
